package niuke;

import java.util.Scanner;

public class 矩阵第k个 {

	public static int kthSmallest(int[][] matrix, int k) {
		if (matrix == null || matrix.length == 0) {
			return 0;
		}
		int result = 0;
		int[] row = new int[matrix.length];
		for (int i = 0; i < row.length; i++) {
			row[i] = 0;
		}
		for (int j = 0; j < k; j++) {
			int flag = 0;
			int temp = Integer.MAX_VALUE;
			for (int i = 0; i < row.length; i++) {
				if (row[i] < matrix[0].length) {
					if (matrix[i][row[i]] < temp) {
						temp = matrix[i][row[i]];
						flag = i;
					}
				}
			}
			row[flag]++;
			result = temp;
		}
		return result;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] array = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				array[i][j] = in.nextInt();
			}
		}
		int res = kthSmallest(array, k);
		System.out.println(res);
	}
}
